import 'package:flutter/material.dart';
import 'package:xinxuan/vo/activities_list_vo.dart';
import 'package:xinxuan/vo/activity_acquisitions_vo.dart';
import 'package:xinxuan/vo/activity_stars_vo.dart';
import 'package:xinxuan/vo/activity_step_vo.dart';
import 'package:xinxuan/vo/activity_subsidies_vo.dart';
import 'package:xinxuan/vo/address_list_vo.dart';
import 'package:xinxuan/vo/adverts_list_vo.dart';
import 'package:xinxuan/vo/ali_pay_vo.dart';
import 'package:xinxuan/vo/announcements_vo.dart';
import 'package:xinxuan/vo/article_detail_vo.dart';
import 'package:xinxuan/vo/articles_list_vo.dart';
import 'package:xinxuan/vo/bank_card_add_edit_vo.dart';
import 'package:xinxuan/vo/bank_card_list_vo.dart';
import 'package:xinxuan/vo/banner_list_vo.dart';
import 'package:xinxuan/vo/blindbox/blind_box_order_detail_vo.dart';
import 'package:xinxuan/vo/blindbox/blindbox_order_list_vo.dart';
import 'package:xinxuan/vo/blindbox/blindbox_products_detail_vo.dart';
import 'package:xinxuan/vo/blindbox/blindbox_submit_order_vo.dart';
import 'package:xinxuan/vo/blindbox/receive_user_list_vo.dart';
import 'package:xinxuan/vo/blindbox/store_list_vo.dart';
import 'package:xinxuan/vo/blindbox/store_time_list_vo.dart';
import 'package:xinxuan/vo/blindbox/writeoff_vo.dart';
import 'package:xinxuan/vo/categoires_list_vo.dart';
import 'package:xinxuan/vo/displacement_list_vo.dart';
import 'package:xinxuan/vo/entrust_vo.dart';
import 'package:xinxuan/vo/features_list_vo.dart';
import 'package:xinxuan/vo/gift_list_vo.dart';
import 'package:xinxuan/vo/gift_order_detail_vo.dart';
import 'package:xinxuan/vo/gift_order_list_vo.dart';
import 'package:xinxuan/vo/good_detail_vo.dart';
import 'package:xinxuan/vo/gratitudes_vo.dart';
import 'package:xinxuan/vo/identities_vo.dart';
import 'package:xinxuan/vo/msg_vo.dart';
import 'package:xinxuan/vo/news_list_vo.dart';
import 'package:xinxuan/vo/order_aggregates_vo.dart';
import 'package:xinxuan/vo/order_detail_vo.dart';
import 'package:xinxuan/vo/pay_verification_vo.dart';
import 'package:xinxuan/vo/products_list_vo.dart';
import 'package:xinxuan/vo/promises_list_vo.dart';
import 'package:xinxuan/vo/seckill_detail_vo.dart';
import 'package:xinxuan/vo/seckill_holder_products_vo.dart';
import 'package:xinxuan/vo/seckill_list_vo.dart';
import 'package:xinxuan/vo/seckill_my_commodity_list_vo.dart';
import 'package:xinxuan/vo/seckill_order_detail_vo.dart';
import 'package:xinxuan/vo/seckill_order_list_vo.dart';
import 'package:xinxuan/vo/seckill_recovery_vo.dart';
import 'package:xinxuan/vo/seckill_substitute_prices_vo.dart';
import 'package:xinxuan/vo/store_order_list_vo.dart';
import 'package:xinxuan/vo/submit_order_vo.dart';
import 'package:xinxuan/vo/submit_seckill_order_vo.dart';
import 'package:xinxuan/vo/system_address_list_vo.dart';
import 'package:xinxuan/vo/system_bank_and_auth_list_vo.dart';
import 'package:xinxuan/vo/system_bank_list_vo.dart';
import 'package:xinxuan/vo/team_members_vo.dart';
import 'package:xinxuan/vo/team_spaces_vo.dart';
import 'package:xinxuan/vo/union_pay_vo.dart';
import 'package:xinxuan/vo/upload_image_vo.dart';
import 'package:xinxuan/vo/user_data_vo.dart';
import 'package:xinxuan/vo/user_invitations_vo.dart';
import 'package:xinxuan/vo/user_login_vo.dart';
import 'package:xinxuan/vo/verification_vo.dart';
import 'package:xinxuan/vo/version_vo.dart';
import 'package:xinxuan/vo/withdrawal_list_vo.dart';
import 'package:xinxuan/vo/wx_pay_vo.dart';
import 'package:dio/dio.dart';

import 'http_util.dart';

class HttpUtilService {

  /// 获取验证码
  static Future<VerificationVo?> getVerificationCode({ required String mobile, required String type, bool loading = true }) async {
    Map<String, dynamic> param = {
      'mobile': mobile,
      'type': type,
    };
    return VerificationVo.fromJson(await HttpUtil.instance.get('/system/verification/codes', data: param, loading: loading));
  }
  
  /// 验证码登录
  static Future<UserLoginVo> verificationCodeLogin({ required String mobile, required String verificationCode, required String verificationKey, bool loading = true }) async {
    Map<String, dynamic> param = {
      'mobile': mobile,
      'verification_code': verificationCode,
      'verification_key': verificationKey
    };
    return UserLoginVo.fromJson(await HttpUtil.instance.post('/auth/login', data: param, loading: loading));
  }
  
  /// 密码登录
  static Future<UserLoginVo> passwordLogin({ required String mobile, required String password, bool loading = true }) async {
    Map<String, dynamic> param = {
      'mobile': mobile,
      'password': password,
    };
    return UserLoginVo.fromJson(await HttpUtil.instance.post('/auth/login', data: param, loading: loading));
  }
  
  /// 获取用户信息
  static Future<UserDataVo> getUserInfo({ bool loading = true }) async {
   return UserDataVo.fromJson(await HttpUtil.instance.get('/user/users/me', loading: loading));
  }

  /// 获取分类列表
  static Future<CategoiresListVo> getCategoiresList({ bool loading = true }) async {
    return CategoiresListVo.fromJson(await HttpUtil.instance.get('/product/categoires', loading: loading));
  }
  
  /// 获取首页banner
  static Future<BannerListVo> getBannersList({ bool loading = true }) async {
    return BannerListVo.fromJson(await HttpUtil.instance.get('/system/banners', loading: loading));
  }
  
  /// 获取首页活动
  static Future<ActivitiesListVo> getActivitiesList({ bool loading = true }) async {
    return ActivitiesListVo.fromJson(await HttpUtil.instance.get('/activity/activities', loading: loading));
  }
  
  /// 获取商品列表(搜索)
  static Future<ProductsListVo> getProductsList({ required String orderType, required String sort, int categoryId = 0, String keyword = '', int page = 1, bool loading = true }) async {
    Map<String, dynamic> param = {
      'page': page,
      'keyword': keyword,
      'order_type': orderType,
      'sort': sort,
      'category_id': categoryId,
    };
    return ProductsListVo.fromJson(await HttpUtil.instance.get('/product/products', data: param, loading: loading));
  }
  
  /// 获取活动商品列表
  static Future<ProductsListVo> getActivityGoodList({ required int activityId, required String orderType, required String sort, String keyword = '', int page = 1, bool loading = true }) async {
    Map<String, dynamic> param = {
      'page': page,
      'keyword': keyword,
      'order_type': orderType,
      'sort': sort,
      'activity_id': activityId
    };
    return ProductsListVo.fromJson(await HttpUtil.instance.get('/activity/products', data: param, loading: loading));
  }

  /// 首页公告列表
  static Future<AdvertsListVo> getAdvertsList({ bool loading = true }) async {
    return AdvertsListVo.fromJson(await HttpUtil.instance.get('/system/adverts', loading: loading));
  }
  
  /// 首页精选好物
  static Future<FeaturesListVo> getFeaturesList({ int page = 1, bool loading = true }) async {
    Map<String, dynamic> param = {
      'page': page
    };
    return FeaturesListVo.fromJson(await HttpUtil.instance.get('/activity/features', data: param, loading: loading));
  }
  
  /// 首页公告
  static Future<NewsListVo> getNewsList({ bool loading = true }) async {
    return NewsListVo.fromJson(await HttpUtil.instance.get('/system/news', loading: loading));
  }
  
  /// 获取精选好物图标
  static Future<PromisesListVo> getPromisesList({ bool loading = true }) async {
    return PromisesListVo.fromJson(await HttpUtil.instance.get('/system/promises', loading: loading));
  }
  
  /// 获取商品详情
  static Future<GoodDetailVo> getGoodDetail({ required int goodId, bool loading = true }) async {
    return GoodDetailVo.fromJson(await HttpUtil.instance.get('/product/products/$goodId', loading: loading));
  }
  
  /// 各种文章列表，categoryId 可写死
  static Future<ArticlesListVo> getArticlesList({ required int categoryId, bool loading = true }) async {
    Map<String, dynamic> param = {
      'category_id': categoryId
    };
    return ArticlesListVo.fromJson(await HttpUtil.instance.get('/article/articles', data: param, loading: loading));
  }
  
  /// 获取文章详情
  static Future<ArticleDetailVo> getArticleDetail({ required int articleId, bool loading = true }) async {
    return ArticleDetailVo.fromJson(await HttpUtil.instance.get('/article/articles/$articleId', loading: loading));
  }
  
  /// 修改用户信息
  static Future<UserDataVo> editUser({ required Map<String, dynamic> param, bool loading = true }) async {
    return UserDataVo.fromJson(await HttpUtil.instance.post('/user/users', data: param, loading: loading));
  }

  /// 修改密码
  static Future<bool> editPassword({ required String verificationCode, required String password, required String verificationKey, bool loading = true }) async {
    Map<String, dynamic> param = {
      'verification_code': verificationCode,
      'password': password,
      'verification_key': verificationKey
    };
    var res = await HttpUtil.instance.post('/user/login/passwords', data: param, loading: loading);
    if (res != null) {
      return true;
    }
    return false;
  }

  // // /// 获取实名认证信息
  // static Future<AuthenticationVo> getAuthenticationData({ bool loading = true }) async {
  //   return AuthenticationVo.fromJson(await HttpUtil.instance.get('/user/identities', loading: loading));
  // }

  /// 实名认证
  static Future<IdentitiesVo> userAuthentication({ required String realname, required String number, bool loading = true }) async {
    Map<String, dynamic> param = {
      'realname': realname,
      'number': number,
      // 'image_ids': imageIds,
    };
    return IdentitiesVo.fromJson(await HttpUtil.instance.post('/user/identities', data: param, loading: loading));
  }


  /// 获取系统银行卡
  static Future<SystemBankListVo> getSystemBankList({ int type = 1, bool loading = true }) async {
    Map<String, dynamic> param = {
      'channel': 0,
      'type': type
    };
    return SystemBankListVo.fromJson(await HttpUtil.instance.get('/system/banks', data: param, loading: loading));
  }

  /// 获取快捷支付系统银行卡及认证信息
  static Future<SystemBankAndAuthListVo> getSystemBankAndAuthList({ int channel = 0, bool loading = true }) async {
    Map<String, dynamic> param = {
      'channel': channel
    };
    return SystemBankAndAuthListVo.fromJson(await HttpUtil.instance.get('/system/banks', data: param, loading: loading));
  }
  
  /// 获取银行卡列表
  static Future<BankCardListVo> getBankCardList({ int type = 0, bool loading = true }) async {
    Map<String, dynamic> param = {
      'type': type
    };
    return BankCardListVo.fromJson(await HttpUtil.instance.get('/user/pay/collections', data: param, loading: loading));
  }

  /// 添加银行卡
  static Future<BankCardAddEditVo> addBankCard({ required String accountName, required String cardNumber, required int isDefault, required int bankId, required String verificationCode, required String identityNumber, required String verificationKey, required String subbranch, int type = 1, bool loading = true }) async {
    Map<String, dynamic> param = {
      'account_name': accountName,
      'card_number': cardNumber,
      'is_default': isDefault,
      'bank_id': bankId,
      'verification_code': verificationCode,
      'identity_number': identityNumber,
      'type': type,
      'verification_key': verificationKey,
      'subbranch': subbranch,
    };
    return BankCardAddEditVo.fromJson(await HttpUtil.instance.post('/user/pay/collections', data: param, loading: loading));
  }

  /// 修改银行卡
  static Future<bool> editBankCard({ required int id, required String accountName, required String cardNumber, required int isDefault, required int bankId, required String verificationCode, required String identityNumber, required String verificationKey, required String subbranch, int type = 1, bool loading = true }) async {
    Map<String, dynamic> param = {
      'account_name': accountName,
      'card_number': cardNumber,
      'is_default': isDefault,
      'bank_id': bankId,
      'verification_code': verificationCode,
      'identity_number': identityNumber,
      'type': type,
      'verification_key': verificationKey,
      'subbranch': subbranch
    };
    var res = await HttpUtil.instance.put('/user/pay/collections/$id', data: param, loading: loading);
    if (res == null) {
      return false;
    }
    return true;
  }
  
  /// 删除银行卡
  static Future<bool> delBankCard({ required int id, bool loading = true }) async {
    var res = await HttpUtil.instance.del('/user/pay/collections/$id', loading: loading);
    if (res == null) {
      return false;
    }
    return true;
  }
  
  /// 邀请加入
  static Future<bool> invitations({ required String invitationCode, bool loading = true }) async {
    Map<String, dynamic> param = {
      'invitation_code': invitationCode
    };
    var res = await HttpUtil.instance.post('/user/invitations', data: param, loading: loading);
    if (res == null) {
      return false;
    }
    return true;
  }
  
  /// 获取系统地址列表
  static Future<SystemAddressListVo> getSystemRegions({ int parentId = 0, bool loading = true }) async {
    Map<String, dynamic> param = {
      'parent_id': parentId
    };
    return SystemAddressListVo.fromJson(await HttpUtil.instance.get('/system/regions', data: param, loading: loading));
  }

  /// 获取收货地址列表
  static Future<AddressListVo> getAddressList({ bool loading = true }) async {
    return AddressListVo.fromJson(await HttpUtil.instance.get('/user/addresses', loading: loading));
  }

  /// 添加收货地址
  static Future<bool> addAddress({ required Map<String, dynamic> map, bool loading = true }) async {
    var res = await HttpUtil.instance.post('/user/addresses', data: map, loading: loading);
    if (res == null) {
      return false;
    }
    return true;
  }
  
  /// 修改收货地址
  static Future<bool> editAddress({ required int id, required Map<String, dynamic> map, bool loading = true }) async {
    var res = await HttpUtil.instance.put('/user/addresses/$id', data: map, loading: loading);
    if (res == null) {
      return false;
    }
    return true;
  }
  
  /// 删除收货地址
  static Future<bool> delAddress({ required int id, bool loading = true }) async {
    var res = await HttpUtil.instance.del('/user/addresses/$id', loading: loading);
    if (res == null) {
      return false;
    }
    return true;
  }
  
  /// 提交反馈
  static Future<bool> submitFeedback({ required String content, required String contact, bool loading = true }) async {
    Map<String, dynamic> param = {
      'content': content,
      'contact': contact,
    };
    var res = await HttpUtil.instance.post('/user/feedbacks', data: param, loading: loading);
    if (res == null) {
      return false;
    }
    return true;
  }
  
  /// 提交会员申请
  static Future<bool> submitUpgrades({ required String reason, bool loading = true }) async {
    Map<String, dynamic> param = {
      'reason': reason,
    };
    var res = await HttpUtil.instance.post('/user/upgrades', data: param, loading: loading);
    if (res == null) {
      return false;
    }
    return true;
  }

  /// 检查版本
  static Future<VersionVo> checkVersion({ bool loading = true }) async {
    return VersionVo.fromJson(await HttpUtil.instance.get('/system/versions/latest', loading: loading));
  }
  
  /// 提交商城订单
  static Future<SubmitOrderVo> submitStoreOrder({ required int productId, required int skuId, required int quantity, required int addressId, bool loading = true }) async {
    Map<String, dynamic> param = {
      'product_id': productId,
      'sku_id': skuId,
      'quantity': quantity,
      'address_id': addressId,
    };
    return SubmitOrderVo.fromJson(await HttpUtil.instance.post('/order/orders', data: param, loading: loading));
  }
  
  /// 获取商城订单详情
  static Future<OrderDetailVo> getStoreOrderDetail({ required int orderId, bool loading = true }) async {
    return OrderDetailVo.fromJson(await HttpUtil.instance.get('/order/orders/$orderId', loading: loading));
  }
  
  /// 获取抢购商品列表
  static Future<SeckillListVo> getSeckillList({ required int page, bool loading = true }) async {
    Map<String, dynamic> param = {
      'page': page
    };
    return SeckillListVo.fromJson(await HttpUtil.instance.get('/seckill/holder/seckills', data: param, loading: loading));
  }
  
  /// 获取抢购商品详情
  static Future<SeckillDetailVo> getSeckillDetail({ required int id, bool loading = true }) async {
    return SeckillDetailVo.fromJson(await HttpUtil.instance.get('/seckill/holder/seckills/$id', loading: loading));
  }
  
  /// 获取商城订单列表
  static Future<StoreOrderListVo> getStoreOrderList({ required int status, String type = '-1', int page = 1, bool loading = true }) async {
    Map<String, dynamic> param = {
      'page': page,
      'status': status,
      'type': type
    };
    return StoreOrderListVo.fromJson(await HttpUtil.instance.get('/order/orders', data: param, loading: loading));
  }
  
  /// 生成抢购订单
  static Future<SubmitSeckillOrderVo?> submitSeckillOrder({ required int productId, required int holderId, bool loading = true }) async {
    Map<String, dynamic> param = {
      'product_id': productId,
      'holder_id': holderId,
      'quantity': 1
    };
    var res = await HttpUtil.instance.post('/seckill/order/orders', data: param, loading: loading);
    if (res == null) {
      return null;
    }
    return SubmitSeckillOrderVo.fromJson(res);
  }
  
  /// 获取抢购订单详情
  static Future<SeckillOrderDetailVo> getSeckillOrderDetail({ required int orderId, bool loading = true }) async {
    return SeckillOrderDetailVo.fromJson(await HttpUtil.instance.get('/seckill/order/orders/$orderId', loading: loading));
  }

  /// 获取抢购订单列表
  static Future<SeckillOrderListVo> getSeckillOrderList({ required int status, required String teamId, int page = 1, bool loading = true }) async {
    Map<String, dynamic> param = {
      'page': page,
      'status': status,
      'team_id': teamId,
    };
    return SeckillOrderListVo.fromJson(await HttpUtil.instance.get('/seckill/order/orders', data: param, loading: loading));
  }
  
  /// 抢购订单确认付款
  static Future<bool> seckillOrderConfirmPayment({ required int orderId, bool loading = true }) async {
    var res = await HttpUtil.instance.put('/seckill/order/payments/$orderId', loading: loading);
    if (res == null) {
      return false;
    }
    return true;
  }

  /// 抢购订单确认收款
  static Future<bool> seckillOrderConfirmReceipt({ required int orderId, bool loading = true }) async {
    var res = await HttpUtil.instance.put('/seckill/order/receives/$orderId', loading: loading);
    if (res == null) {
      return false;
    }
    return true;
  }
  
  /// 我的商品列表（抢购商品）
  static Future<SeckillMyCommodityListVo> getMyCommodityList({ int page = 1, bool loading = true }) async {
    Map<String, dynamic> param = {
      'page': page
    };
    return SeckillMyCommodityListVo.fromJson(await HttpUtil.instance.get('/seckill/holder/products', data: param, loading: loading));
  }
  
  /// 获取置换列表
  static Future<DisplacementListVo> getDisplacementList({ required int productId, bool loading = true }) async {
    Map<String, dynamic> param = {
      'product_id': productId
    };
    return DisplacementListVo.fromJson(await HttpUtil.instance.get('/seckill/product/products', data: param, loading: loading));
  }

  /// 确认置换
  static Future<EntrustVo?> onfirmEntrust({ required int productId, required int holderId, bool loading = true }) async {
    Map<String, dynamic> param = {
      'product_id': productId,
      'holder_id': holderId,
    };
    var res = await HttpUtil.instance.post('/seckill/substitute/orders', data: param, loading: loading);
    if (res == null) {
      return null;
    }
    return EntrustVo.fromJson(res);
  }

  /// 微信支付
  static Future<WxPayVo?> wxPay({ required String orderSn, int orderType = 1, bool loading = true }) async {
    Map<String, dynamic> param = {
      'order_sn': orderSn,
      'order_type': orderType,
    };
    var res = await HttpUtil.instance.get('/pay/wechat/app', data: param, loading: loading);
    if (res == null) {
      return null;
    }
    return WxPayVo.fromJson(res);
  }

  /// 支付宝支付
  static Future<AliPayVo?> aliPay({ required String orderSn, int orderType = 1, bool loading = true }) async {
    Map<String, dynamic> param = {
      'order_sn': orderSn,
      'order_type': orderType,
    };
    var res = await HttpUtil.instance.get('/pay/alipay/app', data: param, loading: loading);
    if (res == null) {
      return null;
    }
    return AliPayVo.fromJson(res);
  }
  
  /// 银联支付
  static Future<bool> bankPay({ required String orderSn, required int fastPaymentId, required String password, int orderType = 1, bool loading = true }) async {
    Map<String, dynamic> param = {
      'order_sn': orderSn,
      'order_type': orderType,
      'payment_id': fastPaymentId,
      'password': password,
    };
    var res = await HttpUtil.instance.get('/pay/joinpay/fastpay/pay', data: param, loading: loading);
    if (res == null) {
      return false;
    }
    return true;
  }

  /// 感恩值支付
  static Future<bool> gratitudePay({ required String orderSn, required String password, bool loading = true }) async {
    Map<String, dynamic> param = {
      'order_sn': orderSn,
      'password': password
    };
    var res = await HttpUtil.instance.post('/pay/gratitude', data: param, loading: loading);
    if (res == null) {
      return false;
    }
    return true;
  }

  /// 商城订单取消订单
  static Future<bool> storeOrderCancel({ required int orderId, bool loading = true }) async {
    var res = await HttpUtil.instance.put('/order/cancel/$orderId', loading: loading);
    if (res == null) {
      return false;
    }
    return true;
  }

  /// 商城订单确认收货
  static Future<bool> storeOrderReceive({ required int orderId, bool loading = true }) async {
    var res = await HttpUtil.instance.put('/order/receive/$orderId', loading: loading);
    if (res == null) {
      return false;
    }
    return true;
  }

  /// 获取空间统计
  static Future<TeamSpacesVo> getTeamSpaces({ bool loading = true }) async {
    return TeamSpacesVo.fromJson(await HttpUtil.instance.get('/team/spaces', loading: loading));
  }

  /// 获取团队表现
  static Future<TeamMembersVo> getTeamMembers({ int page = 1, bool loading = true }) async {
    Map<String, dynamic> param = {
      'page': page
    };
    return TeamMembersVo.fromJson(await HttpUtil.instance.get('/team/members', data: param, loading: loading));
  }

  /// 获取置换价格
  static Future<SeckillSubstitutePricesVo> getSeckillSubstitutePrices({ required int holderProductId, required int substituteProductId, bool loading = true }) async {
    Map<String, dynamic> param = {
      'holder_product_id': holderProductId,
      'substitute_product_id': substituteProductId,
    };
    return SeckillSubstitutePricesVo.fromJson(await HttpUtil.instance.get('/seckill/substitute/prices', data: param, loading: loading));
  }

  /// 注销账号
  static Future<bool> cancelAccount({ bool loading = true }) async {
    var res = await HttpUtil.instance.del('/user/users/1', loading: loading);
    if (res == null) {
      return false;
    }
    return true;
  }
  
  /// 获取提现记录
  static Future<WithdrawalListVo> getWithdrawalRecordList({ int page = 1, bool loading = true }) async {
    Map<String, dynamic> param = {
      'page': page
    };
    return WithdrawalListVo.fromJson(await HttpUtil.instance.get('/finance/withdraws', data: param, loading: loading));
  }
  
  /// 申请提现
  static Future<bool> withdrawal({ required String amount, required String verificationCode, required int paymentId, required String verificationKey, bool loading = true }) async {
    Map<String, dynamic> param = {
      'amount': amount,
      'verification_code': verificationCode,
      'payment_id': paymentId,
      'verification_key': verificationKey
    };
    var res = await HttpUtil.instance.post('/finance/withdraws', data: param, loading: loading);
    if (res == null) {
      return false;
    }
    return true;
  }

  /// 一键回收
  static Future<bool> seckillRecovery({ bool loading = true }) async {
    var res = await HttpUtil.instance.post('/seckill/recovery/products', loading: loading);
    if (res == null) {
      return false;
    }
    return true;
  }
  
  /// 获取回收列表
  static Future<SeckillRecoveryVo> getSeckillRecoveryList({ required int status, int page = 1, bool loading = true }) async {
    Map<String, dynamic> param = {
      'page': page,
      'status': status
    };
    return SeckillRecoveryVo.fromJson(await HttpUtil.instance.get('/seckill/recovery/products', data: param, loading: loading));
  }
  
  /// 确认回收
  static Future<bool> recoveryProducts({ required int id, bool loading = true }) async {
    var res = await HttpUtil.instance.put('/seckill/recovery/products/$id', loading: loading);
    if (res != null) {
      return true;
    }
    return false;
  }
  
  /// 获取置换商品详情
  static Future<SeckillHolderProductsVo> getSeckillHolderProductsDetail({ required int productId, bool loading = true }) async {
    return SeckillHolderProductsVo.fromJson(await HttpUtil.instance.get('/seckill/holder/products/$productId', loading: loading));
  }
  
  /// 获取赠品列表
  static Future<GiftListVo> getGiftList({ required int page, bool loading = true }) async {
    Map<String, dynamic> param = {
      'page': page
    };
    return GiftListVo.fromJson(await HttpUtil.instance.get('/gift/holder/products', data: param, loading: loading));
  }
  
  /// 提交赠品订单
  static Future<bool> submitGiftOrder({ required int holderId, required int addressId, required int quantity, String expressId = '10001', bool loading = true }) async {
    Map<String, dynamic> param = {
      'holder_id': holderId,
      'address_id': addressId,
      'quantity': quantity,
      'express_id': expressId
    };
    var res = await HttpUtil.instance.post('/gift/order/orders', data: param, loading: loading);
    if (res == null) {
      return false;
    }
    return true;
  }

  /// 获取赠品订单列表
  static Future<GiftOrderListVo> getGitfOrderList({ int page = 1, bool loading = true }) async {
    Map<String, dynamic> param = {
      'page': page
    };
    return GiftOrderListVo.fromJson(await HttpUtil.instance.get('/gift/order/orders', data: param, loading: loading));
  }
  
  /// 获取赠品订单详情
  static Future<GiftOrderDetailVo> getGiftOrderDetail({ required int orderId, bool loading = true }) async {
    return GiftOrderDetailVo.fromJson(await HttpUtil.instance.get('/gift/order/orders/$orderId', loading: loading));
  }

  // /// 获取快捷支付系统银行卡及认证信息
  // static Future<SystemBankAndAuthListVo> getSystemBankAndAuthList({ bool loading = true }) async {
  //   return SystemBankAndAuthListVo.fromJson(await HttpUtil.instance.get('/pay/fastpay/banks', loading: loading));
  // }
  
  /// 获取快捷支付系统银行卡及认证信息
  static Future<PayVerificationVo?> getPaySmsCode({ 
    required int identityType, 
    required String identityNumber, 
    required String accountName,
    required String cardNumber,
    required String mobile,
    required int bankId, 
    bool loading = true }) async {
    Map<String, dynamic> param = {
      'type': 1,
      'account_name': accountName,
      'card_number': cardNumber,
      'bank_id': bankId,
      'identity_type': identityType,
      'identity_number': identityNumber,
      'mobile': mobile,
    };
    return PayVerificationVo.fromJson(await HttpUtil.instance.post('/pay/verification', data: param, loading: loading));
  }
  
  /// 确认添加支付银行卡
  static Future<BankCardAddEditVo?> determineAddPayBank({ 
    required String verificationCode, 
    required int paymentId,
    required String password,
    required String verificationKey,
    bool loading = true }) async {
    Map<String, dynamic> param = {
      'verification_code': verificationCode,
      'payment_id': paymentId,
      'password': password,
      'verification_key': verificationKey,
    };
    return BankCardAddEditVo.fromJson(await HttpUtil.instance.post('/user/pay/payments', data: param, loading: loading));
  }
  
  /// 解绑支付银行卡
  static Future<bool> unboundAddPayBank({ required int paymentId, required String verificationCode, required String verificationKey, bool loading = true }) async {
    Map<String, dynamic> param = {
      'verification_code': verificationCode,
      'verification_key': verificationKey
    };
    var res = await HttpUtil.instance.del('/user/pay/payments/$paymentId', data: param, loading: loading);
    if (res == null) {
      return false;
    }
    return true;
  }
  
  /// 获取支付银行卡列表
  static Future<BankCardListVo> getPayBankList({ bool loading = true }) async {
    return BankCardListVo.fromJson(await HttpUtil.instance.get('/user/pay/payments', loading: loading));
  }
  
  /// 修改支付密码
  static Future<bool> updatePayPassword({ required String verificationCode, required String password, required String verificationKey, bool loading = true }) async {
    Map<String, dynamic> param = {
      'verification_code': verificationCode,
      'password': password,
      'verification_key': verificationKey
    };
    var res = await HttpUtil.instance.post('/user/pay/passwords', data: param, loading: loading);
    if (res == null) {
      return false;
    }
    return true;
  }

  /// 云闪付支付
  static Future<UnionPayVo?> unionPay({ required String orderSn, int orderType = 1, bool loading = true }) async {
    Map<String, dynamic> param = {
      'order_sn': orderSn,
      'order_type': orderType,
    };
    var res = await HttpUtil.instance.get('/pay/joinpay/union', data: param, loading: loading);
    if (res == null) {
      return null;
    }
    return UnionPayVo.fromJson(res);
  }
  
  /// 获取星选专区
  static Future<ActivityStarsVo> getActivityStars({ int page = 1, String price = '', bool loading = true }) async {
    Map<String, dynamic> param;
    if (price.isEmpty) {
      param = {
        'page': page
      };
    } else {
      param = {
        'page': page,
        'price': price
      };
    }
    return ActivityStarsVo.fromJson(await HttpUtil.instance.get('/activity/stars', data: param, loading: loading));
  }

  /// 获取公告
  static Future<AnnouncementsVo?> getAnnouncements({ int type = 1, bool loading = true }) async {
    Map<String, dynamic> param = {
      'type': type,
      'latest': 1
    };
    var res = await HttpUtil.instance.get('/system/announcements', data: param, loading: loading);
    if (res is String) {
      return null;
    }
    return AnnouncementsVo.fromJson(res);
  }

  /// 上传图片
  static Future<UploadImageVo> uploadImage(FormData formdata) async {
    return UploadImageVo.fromJson(await HttpUtil().formPost('/system/upload', data: formdata));
  }

  /// 获取实名认证信息
  static Future<IdentitiesVo> getUserIdentities({ bool loading = true }) async {
    return IdentitiesVo.fromJson(await HttpUtil().get('/user/identities', loading: loading));
  }

  /// 获取活动状态
  static Future<ActivityAcquisitionsVo> getActivityAcquisitions({ bool loading = true }) async {
    return ActivityAcquisitionsVo.fromJson(await HttpUtil().get('/activity/acquisitions', loading: loading));
  }
  
  /// 获取活动状态
  static Future<ActivityStepVo> activityStep({ required int step, bool loading = true }) async {
    Map<String, dynamic> param = {
      'step': step
    };
    return ActivityStepVo.fromJson(await HttpUtil().post('/activity/acquisitions', data: param, loading: loading));
  }
  
  /// 获取我的邀请
  static Future<UserInvitationsVo> getUserInvitations({ int isPurchased = -1, int page = 1, bool loading = true }) async {
    Map<String, dynamic> param = {
      'is_purchased': isPurchased,
      'page': page,
    };
    return UserInvitationsVo.fromJson(await HttpUtil().get('/user/invitations', data: param, loading: loading));
  }
  
  /// 获取我的补贴金发放列表
  static Future<ActivitySubsidiesVo> getActivitySubsidies({ int page = 1, bool loading = true }) async {
    Map<String, dynamic> param = {
      'page': page,
    };
    return ActivitySubsidiesVo.fromJson(await HttpUtil().get('/invitation/subsidies', data: param, loading: loading));
  }
  
  /// 获取秒杀待付款汇总
  static Future<OrderAggregatesVo> getOrderAggregates({ int page = 1, bool loading = true }) async {
    Map<String, dynamic> param = {
      'page': page,
    };
    return OrderAggregatesVo.fromJson(await HttpUtil().get('/seckill/order/aggregates', data: param, loading: loading));
  }

  /// 下载文件
  static Future<int> downloadFile({required String name, required CancelToken cancelToken, ValueChanged<double>? percentChange}) async {
    return HttpUtil().downloadFile(
      urlPath: '/seckill/order/exports', 
      savePath: name,
      percentChange: percentChange,
      cancelToken: cancelToken
    );
  }
  /// 获取盲盒详情
  static Future<BlindboxProductsDetailVo> getBlindboxProductDetail({ required int id, bool loading = true}) async {
    return BlindboxProductsDetailVo.fromJson(await HttpUtil.instance.get('/blindbox/package/packages/$id', loading: loading));
  }

  /// 提交盲盒订单
  static Future<BlindBoxSubmitOrderVo> submitBlindBoxOrder({ required int id, required String password, bool loading = true}) async {
    Map<String, dynamic> param = {
      'id': id,
      'password': password,
    };
    return BlindBoxSubmitOrderVo.fromJson(await HttpUtil.instance.post('/blindbox/order/orders', data: param, loading: loading));
  }

  /// 获取盲盒订单详情
  static Future<BlindBoxOrderDetailVo> getBlindBoxOrderDetail({ required int orderId, bool loading = true }) async {
    return BlindBoxOrderDetailVo.fromJson(await HttpUtil.instance.get('/blindbox/order/orders/$orderId', loading: loading));
  }

  /// 获取盲盒订单列表
  static Future<BlindBoxOrderListVo> getBlindBoxOrderList({ required int status, int page = 1, bool loading = true }) async {
    Map<String, dynamic> param = {
      'page': page,
      'status': status,
      'include': 'packages,lottery'
    };
    return BlindBoxOrderListVo.fromJson(await HttpUtil.instance.get('/blindbox/order/orders', data: param, loading: loading));
  }

  /// 获取接受人列表
  static Future<ReceiveUserListVo?> getReceiveUserList({ required String mobile, bool loading = true }) async {
    Map<String, dynamic> param = {
      'mobile': mobile
    };
    var res = await HttpUtil.instance.get('/user/users', data: param, loading: loading);
    if (res == null) {
      return null;
    }
    return ReceiveUserListVo.fromJson(res);
  }

  /// 确认赠送
  static Future<bool> confirmGift({ required String receiver, required int orderId, bool loading = true }) async {
    Map<String, dynamic> param = {
      'receiver': receiver,
      'order_id': orderId
    };
    var res = await HttpUtil.instance.post('/blindbox/order/transfer', data: param, loading: loading);
    if (res != null) {
      return true;
    }
    return false;
  }
  
  /// 获取门店列表
  static Future<StoreListVo> getStores({ String title = '', int page = 1, bool loading = true }) async {
    Map<String, dynamic> param = {
      'page': page,
      'title': title,
    };
    return StoreListVo.fromJson(await HttpUtil.instance.get('/store/stores', data: param, loading: loading));
  }

  /// 获取门店可预约时间列表
  static Future<StoreTimeListVo> getStoreTimeList({ required int id, bool loading = true }) async {
    return StoreTimeListVo.fromJson(await HttpUtil.instance.get('/store/stores/$id', loading: loading));
  }
  
  /// 预约门店
  static Future<bool> submitStoreMark({ required int orderId, required int storeId, required String pickTime, bool loading = true }) async {
    Map<String, dynamic> param = {
      'order_id': orderId,
      'store_id': storeId,
      'pick_time': pickTime,
    };
    var res = await HttpUtil.instance.post('/store/orders', data: param, loading: loading);
    if (res != null) {
      return true;
    }
    return false;
  }

  /// 扫码获取核销商品数据
  static Future<WriteoffVo> getWriteoffData({ required String code, bool loading = true }) async {
    return WriteoffVo.fromJson(await HttpUtil.instance.get('/store/writeoff/$code', loading: loading));
  }

  /// 扫码核销商品数据（商品）
  static Future<MsgVo?> writeoffData({ required String code, bool loading = true }) async {
    var res = await HttpUtil.instance.put('/store/writeoff/$code', loading: loading);
    if (res is String) {
      return null;
    }
    return MsgVo.fromJson(res);
  }

  /// 核销商品数据（转款）
  static Future<MsgVo?> checkoff({ required int id, bool loading = true }) async {
    var res = await HttpUtil.instance.put('/blindbox/order/checkoff/$id', loading: loading);
    if (res is String) {
      return null;
    }
    return MsgVo.fromJson(res);
  }
  
  /// 获取回馈感恩值数据
  static Future<GratitudesVo> getGratitudeRecord({ int page = 1, bool loading = true }) async {
    Map<String, dynamic> param = {
      'page': page
    };
    return GratitudesVo.fromJson(await HttpUtil.instance.get('/blindbox/order/gratitudes', data: param, loading: loading));
  }

}

